package com.huawei.appmarket.service.webview.js;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.AsyncTask.Status;
import android.os.Build.VERSION;
import android.text.ClipboardManager;
import android.text.Html;
import android.text.TextUtils;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import com.huawei.appgallery.datastorage.provider.CommonFileProvider;
import com.huawei.appgallery.forum.user.api.IUserHomePageProtocol;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appmarket.service.config.protocol.AppLaunchProtocol;
import com.huawei.fastengine.fastview.FastSDKEngine;
import com.huawei.fastengine.fastview.startFastappEngine.bean.RpkInfo;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import o.azj;
import o.azt;
import o.azu;
import o.bmo;
import o.AccountBussinessListener;
import o.ccp;
import o.ccz;
import o.ced;
import o.PermissionChecker;
import o.HcridSession;
import o.cjk;
import o.cjm;
import o.cjo;
import o.cks;
import o.cku;
import o.cuq;
import o.cut;
import o.BaseRequest;
import o.der.f;
import o.dgh;
import o.dgm;
import o.Logger;
import o.dof;
import o.doo;
import o.ContentManager;
import o.dse;
import o.dxz;
import o.dzo;
import o.ear;
import o.ebz;
import o.efe;
import o.emz;
import o.ene;
import o.enm;
import o.enn;
import o.enq;
import o.enr;
import o.ens;
import o.ent;
import o.enx;
import o.eod;
import o.eoj;
import o.epp;
import o.eth;
import o.etp;
import o.evk;
import o.ewm.n;
import o.exp$f;
import o.ezl;
import o.fco;
import o.fho;
import o.fiu;
import o.fjb;
import o.ll;
import org.json.JSONException;
import org.json.JSONObject;

public class HiSpaceObject extends ExtraJsObject {
    private static final String LINE_SEPARATOR = "<BR/>";
    private static final int NO_UPLOAD_LOG = 0;
    private static final String TAG = "HiSpaceObject";
    private static final int UPLOAD_LOG = 1;
    private static final String WEBVIEW_PARAMS_CAMPAIGN_ID = "campaignId";
    private boolean canRequestWhiteList = true;
    private boolean isReservingGame = false;
    private long lastUploadTime = 0;
    private int version = 4;

    static class a implements azu {
        private WeakReference<HiSpaceObject> ˋ;
        private d ˏ;

        public a(HiSpaceObject hiSpaceObject, d dVar) {
            this.ˋ = new WeakReference(hiSpaceObject);
            this.ˏ = dVar;
        }

        public void ˊ(boolean z, int i) {
            final HiSpaceObject hiSpaceObject = (HiSpaceObject) this.ˋ.get();
            if (hiSpaceObject != null) {
                if (z) {
                    hiSpaceObject.canRequestWhiteList = false;
                    hiSpaceObject.mHandler.post(new Runnable(this) {
                        final /* synthetic */ a ˋ;

                        public void run() {
                            if (hiSpaceObject.isCanInstall()) {
                                this.ˋ.ˏ.ˏ();
                                return;
                            }
                            Logger.ˋ(HiSpaceObject.TAG, "after request whitelist, not in install list");
                            hiSpaceObject.onRequestWhiteListError(1);
                        }
                    });
                    return;
                }
                hiSpaceObject.onRequestWhiteListError(i);
            }
        }
    }

    public interface d {
        void ˏ();
    }

    static class b implements d {
        private JSONObject ˎ;
        private WeakReference<HiSpaceObject> ॱ;

        public b(HiSpaceObject hiSpaceObject, JSONObject jSONObject) {
            this.ॱ = new WeakReference(hiSpaceObject);
            this.ˎ = jSONObject;
        }

        public void ˏ() {
            HiSpaceObject hiSpaceObject = (HiSpaceObject) this.ॱ.get();
            if (hiSpaceObject != null) {
                hiSpaceObject.startDownloadApk(this.ˎ);
            }
        }
    }

    static class c extends AsyncTask<Object, Void, Boolean> {
        private WeakReference<HiSpaceObject> ॱ;

        protected /* synthetic */ Object doInBackground(Object[] objArr) {
            return ˊ(objArr);
        }

        protected /* synthetic */ void onPostExecute(Object obj) {
            ˎ((Boolean) obj);
        }

        public c(HiSpaceObject hiSpaceObject) {
            this.ॱ = new WeakReference(hiSpaceObject);
        }

        protected Boolean ˊ(Object... objArr) {
            return Boolean.valueOf(dse.ˏ(ContentManager.getInstant().getContext()));
        }

        protected void ˎ(Boolean bool) {
            HiSpaceObject hiSpaceObject = (HiSpaceObject) this.ॱ.get();
            if (hiSpaceObject == null) {
                Logger.ˋ(HiSpaceObject.TAG, "get hiSpaceObject null");
            } else if (bool.booleanValue()) {
                hiSpaceObject.showToast(ContentManager.getInstant().getContext().getString(f.ˬ));
            } else {
                hiSpaceObject.showToast(ContentManager.getInstant().getContext().getString(f.ˏꓸ));
            }
        }
    }

    static class e implements d {
        private WeakReference<HiSpaceObject> ˎ;
        private JSONObject ˏ;

        public e(HiSpaceObject hiSpaceObject, JSONObject jSONObject) {
            this.ˎ = new WeakReference(hiSpaceObject);
            this.ˏ = jSONObject;
        }

        public void ˏ() {
            HiSpaceObject hiSpaceObject = (HiSpaceObject) this.ˎ.get();
            if (hiSpaceObject != null) {
                hiSpaceObject.downloadApk(this.ˏ);
            }
        }
    }

    public HiSpaceObject(Context context, azt o_azt, WebView webView) {
        super(context, o_azt, webView);
    }

    @JavascriptInterface
    public int getHiSpaceVersion() {
        return this.version;
    }

    @JavascriptInterface
    public void setClipboardText(String str) {
        if (this.mContext != null) {
            setClipboardText(str, null);
        }
    }

    private void setClipboardText(String str, String str2) {
        ((ClipboardManager) this.mContext.getSystemService("clipboard")).setText(str);
        if (dof.ˋ(str2)) {
            str2 = this.mContext.getString(f.ˋʼ);
        }
        showToastImpl(str2);
    }

    @JavascriptInterface
    public void setClipboardMsg(String str, String str2, int i, String str3, String str4) {
        if (this.mContext != null) {
            setClipboardText(str, str2);
            if (1 == i && "gift".equals(str3)) {
                Intent intent = new Intent();
                intent.setAction("com.huawei.gamebox.refreshBuoyGiftCard");
                intent.putExtra("refresh.observer.id", str4);
                intent.putExtra("refresh.observer.value", str);
                ll.ˏ(this.mContext.getApplicationContext()).ˋ(intent);
            }
        }
    }

    @JavascriptInterface
    public void goToConnection(String str) {
        try {
            startActivityIfNewTask(new Intent(ACTION.HWID_SCHEME_URL, Uri.parse(str)));
        } catch (Exception e) {
            Logger.ˋ(TAG, "goToConnection error");
        }
    }

    @JavascriptInterface
    public void skipToTab(String str) {
        if (!dof.ʽ(str)) {
            eod.ˎ(this.mContext);
        }
    }

    @JavascriptInterface
    public void skipToTab(String str, boolean z) {
        skipToTab(str);
        if (z) {
            showToastImpl(this.mContext.getString(f.ˊᶥ));
        }
    }

    @JavascriptInterface
    public void award(String str) {
        cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
        appDetailActivityProtocol.ˏ(new Request(str, null));
        cjk.ˎ().ˋ(this.mContext, new cjm("appdetail.activity", appDetailActivityProtocol));
    }

    @JavascriptInterface
    public void appUpgrade() {
        cjk.ˎ().ˋ(this.mContext, new cjm("apkmgr.activity", null));
    }

    @JavascriptInterface
    public String getSign() {
        return HcridSession.ˋ().ˊ();
    }

    @JavascriptInterface
    public String getUserAccount() {
        UserSession instance = UserSession.getInstance();
        if (instance == null || !instance.isLoginSuccessful()) {
            return null;
        }
        return instance.getAuthAccount();
    }

    @JavascriptInterface
    public String getNickName() {
        return enr.ˎ(this.mContext, this.mWebView, this.mHandler);
    }

    @JavascriptInterface
    public String getUserNickName() {
        return getNickName();
    }

    @JavascriptInterface
    public void login(String str, final String str2) {
        this.mHandler.post(new Runnable(this) {
            final /* synthetic */ HiSpaceObject ˊ;

            public void run() {
                if (UserSession.getInstance().isLoginSuccessful() && this.ˊ.mJsCallBack != null) {
                    this.ˊ.mJsCallBack.ᐝ(str2);
                }
            }
        });
    }

    @JavascriptInterface
    public void startDownload(String str) {
        if (doo.ˊ(this.mContext)) {
            try {
                final JSONObject jSONObject = new JSONObject(str);
                this.mHandler.post(new Runnable(this) {
                    final /* synthetic */ HiSpaceObject ˋ;

                    public void run() {
                        if (this.ˋ.isCanInstall()) {
                            this.ˋ.startDownloadApk(jSONObject);
                        } else {
                            this.ˋ.requestWhiteList(new b(this.ˋ, jSONObject));
                        }
                    }
                });
                return;
            } catch (Exception e) {
                Logger.ˋ(TAG, "startDownload(): Exception ");
                return;
            }
        }
        this.mJsCallBack.ˋ(this.mContext, this.mContext.getString(f.ʻʽ), 1);
    }

    private void startDownloadApk(JSONObject jSONObject) {
        String optString = jSONObject.optString("url");
        ene.ˋ((Activity) this.mContext, jSONObject.optString("packageName"), optString, null);
    }

    @JavascriptInterface
    public void installApp(String str, final String str2) {
        this.mHandler.post(new Runnable(this) {
            final /* synthetic */ HiSpaceObject ˋ;

            public void run() {
                if (this.ˋ.mJsCallBack != null) {
                    this.ˋ.mJsCallBack.ᐝ(str2);
                }
            }
        });
    }

    @JavascriptInterface
    public void dial(String str) {
        ens.ˊ(this.mContext, str);
    }

    @JavascriptInterface
    public void enter(int i) {
        if (i == 2) {
            if ((this.mContext instanceof Activity) && dgm.ˎ((Activity) this.mContext) == 1) {
                cjo appLaunchProtocol = new AppLaunchProtocol();
                appLaunchProtocol.ˊ(new AppLaunchProtocol.Request(false));
                cjm o_cjm = new cjm("gamebox.activity", appLaunchProtocol);
                o_cjm.ॱ(this.mContext).addFlags(67141632);
                cjk.ˎ().ˋ(this.mContext, o_cjm);
            } else {
                cjm o_cjm2 = new cjm("market.activity", null);
                o_cjm2.ॱ(this.mContext).setFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS);
                cjk.ˎ().ˋ(this.mContext, o_cjm2);
            }
            if (this.mContext instanceof Activity) {
                ((Activity) this.mContext).overridePendingTransition(o.der.c.ˏ, o.der.c.ˋ);
            }
        }
    }

    @JavascriptInterface
    public void refreshMyexchange(final String str) {
        if (this.mJsCallBack != null) {
            this.mHandler.post(new Runnable(this) {
                final /* synthetic */ HiSpaceObject ˋ;

                public void run() {
                    this.ˋ.mJsCallBack.ᐝ(str);
                }
            });
        }
    }

    @JavascriptInterface
    public void uploadAppstoreLog() {
        if (this.mContext == null || this.mHandler == null) {
            Logger.ˋ(TAG, "uploadAppstoreLog error,mContext is null");
        } else {
            this.mHandler.post(new Runnable(this) {
                final /* synthetic */ HiSpaceObject ˋ;

                {
                    this.ˋ = r1;
                }

                public void run() {
                    if (doo.ˊ(this.ˋ.mContext)) {
                        long currentTimeMillis = System.currentTimeMillis();
                        if (currentTimeMillis - this.ˋ.lastUploadTime <= 10000) {
                            this.ˋ.showToast(this.ˋ.mContext.getString(f.ʽॱ));
                            return;
                        }
                        this.ˋ.lastUploadTime = currentTimeMillis;
                        this.ˋ.showToast(this.ˋ.mContext.getString(f.ˑˊ));
                        AsyncTask cVar = new c(this.ˋ);
                        if (cVar.getStatus() != Status.RUNNING) {
                            cVar.execute(new Object[0]);
                            return;
                        }
                        return;
                    }
                    this.ˋ.showToast(this.ˋ.mContext.getString(f.ʻʽ));
                }
            });
        }
    }

    @JavascriptInterface
    public String getCommonParams() {
        return this.mJsCallBack.ˎ(this.mContext);
    }

    @JavascriptInterface
    public String getUserId() {
        UserSession instance = UserSession.getInstance();
        if (instance == null || !instance.isLoginSuccessful()) {
            return null;
        }
        return instance.getUserId();
    }

    @JavascriptInterface
    public void bindPhone(final String str) {
        UserSession instance = UserSession.getInstance();
        Logger.ˎ(TAG, " bindPhone start , callback");
        if (instance.isLoginSuccessful()) {
            ((cut) fho.ˏ().ˋ("RealName").ॱ(cut.class)).ˎ(this.mContext.getApplicationContext(), new cuq(this) {
                final /* synthetic */ HiSpaceObject ˊ;

                public void ˊ() {
                    this.ˊ.mHandler.post(new Runnable(this) {
                        final /* synthetic */ AnonymousClass16 ˏ;

                        {
                            this.ˏ = r1;
                        }

                        public void run() {
                            if (this.ˏ.ˊ.mWebView != null) {
                                Logger.ˎ(HiSpaceObject.TAG, "BindPhone SUCCESSED");
                                this.ˏ.ˊ.mWebView.loadUrl(str);
                            }
                        }
                    });
                }
            });
        } else {
            Logger.ˎ(TAG, " bindPhone failed , not login on at this moment");
        }
    }

    @JavascriptInterface
    public void refreshClientST() {
        if (this.mContext != null) {
            enr.ˊ(this.mContext, this.mJsCallBack, this.mHandler);
        }
    }

    @JavascriptInterface
    public void refreshST() {
        refreshClientST();
    }

    @JavascriptInterface
    public String getAppStatus(String str) {
        return ene.ˋ(str);
    }

    @JavascriptInterface
    public void cancelDownload(String str) {
        if (this.mContext instanceof Activity) {
            ene.ˊ((Activity) this.mContext, str);
        } else {
            Logger.e(TAG, "context not activity,can not support cancelDownload interface!");
        }
    }

    @JavascriptInterface
    public void pauseDownload(String str) {
        if (this.mContext instanceof Activity) {
            ene.ˎ((Activity) this.mContext, str);
        } else {
            Logger.e(TAG, "context not activity,can not support cancelDownload interface!");
        }
    }

    @JavascriptInterface
    public void download(String str) {
        if (this.mContext instanceof Activity) {
            try {
                final JSONObject jSONObject = new JSONObject(str);
                this.mHandler.post(new Runnable(this) {
                    final /* synthetic */ HiSpaceObject ˏ;

                    public void run() {
                        if (this.ˏ.isCanInstall()) {
                            this.ˏ.downloadApk(jSONObject);
                        } else {
                            this.ˏ.requestWhiteList(new e(this.ˏ, jSONObject));
                        }
                    }
                });
                return;
            } catch (Exception e) {
                Logger.e(TAG, "download(): Exception ");
                return;
            }
        }
        Logger.e(TAG, "context not activity,can not support download interface!");
    }

    private void downloadApk(JSONObject jSONObject) {
        String optString = jSONObject.optString("downurl");
        String optString2 = jSONObject.optString(HiAnalyticsConstant.BI_KEY_PACKAGE);
        ene.ˋ((Activity) this.mContext, optString2, optString, jSONObject.optString("channelNo"));
        if (!dof.ॱ(optString2)) {
            String substring;
            int indexOf = optString2.indexOf(63);
            if (indexOf != -1) {
                substring = optString2.substring(0, indexOf);
            } else {
                substring = optString2;
            }
            if (!ene.ˊ(substring) && jSONObject.has("detailId")) {
                optString2 = jSONObject.optString("detailId");
                indexOf = ccz.ॱ();
                if (this.mContext instanceof Activity) {
                    indexOf = dgm.ˎ((Activity) this.mContext);
                }
                LinkedHashMap linkedHashMap = new LinkedHashMap();
                linkedHashMap.put("detailid", optString2);
                linkedHashMap.put("service_type", String.valueOf(indexOf));
                dgh.ˋ("wap_installbtn_click", linkedHashMap);
            }
        }
    }

    @JavascriptInterface
    public void launchWebviewActivity(String str, String str2) {
        Logger.ˏ(TAG, "launchWebviewActivity: deleuri: " + str);
        emz.ॱ(this.mContext, str, str2);
    }

    @JavascriptInterface
    public void reserveGame(String str) {
        if (!(this.mContext instanceof Activity)) {
            Logger.e(TAG, "context not activity,can not support reserveGame interface!");
        } else if (!doo.ˊ(this.mContext)) {
            evk.ˋ(this.mContext, this.mContext.getResources().getString(f.ʻʽ), 1).ˋ();
            ene.ˏ(str);
        } else if (this.isReservingGame) {
            Logger.ˎ(TAG, "reserving game...");
        } else {
            this.isReservingGame = true;
            ene.ˏ((Activity) this.mContext, str, new efe(this) {
                final /* synthetic */ HiSpaceObject ˏ;

                {
                    this.ˏ = r1;
                }

                public void ˋ() {
                    this.ˏ.isReservingGame = false;
                }

                public void ˎ(BaseRequest o_cvu, ResponseBean responseBean) {
                    this.ˏ.isReservingGame = false;
                }
            });
        }
    }

    @JavascriptInterface
    public void cancelReserveGame(final String str) {
        if (!(this.mContext instanceof Activity)) {
            Logger.e(TAG, "context not activity,can not support cancelReserveGame interface!");
        } else if (doo.ˊ(this.mContext)) {
            ene.ॱ((Activity) this.mContext, str, new cks(this) {
                final /* synthetic */ HiSpaceObject ˋ;

                public void enableNetworking() {
                    if (this.ˋ.isReservingGame) {
                        Logger.ˎ(HiSpaceObject.TAG, "isReservingGame...");
                        return;
                    }
                    this.ˋ.isReservingGame = true;
                    ene.ˎ((Activity) this.ˋ.mContext, str, new efe(this) {
                        final /* synthetic */ AnonymousClass17 ˎ;

                        {
                            this.ˎ = r1;
                        }

                        public void ˋ() {
                            this.ˎ.ˋ.isReservingGame = false;
                        }

                        public void ˎ(BaseRequest o_cvu, ResponseBean responseBean) {
                            this.ˎ.ˋ.isReservingGame = false;
                        }
                    });
                }

                public void upgrade() {
                    ene.ˏ(str);
                }

                public void ˋ() {
                    ene.ˏ(str);
                }
            });
        } else {
            evk.ˋ(this.mContext, this.mContext.getResources().getString(f.ʻʽ), 1).ˋ();
            ene.ˏ(str);
        }
    }

    @JavascriptInterface
    public boolean isOrderedPkg(String str) {
        return ebz.ॱ().ˎ(str);
    }

    @JavascriptInterface
    public void feedbackByEmail(String str, String str2, final int i) {
        if (doo.ˊ(this.mContext)) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(this.mContext.getString(f.ߴ));
            stringBuilder.append(LINE_SEPARATOR);
            stringBuilder.append(str);
            stringBuilder.append(LINE_SEPARATOR);
            stringBuilder.append(LINE_SEPARATOR);
            stringBuilder.append(this.mContext.getString(f.ՙ));
            stringBuilder.append(LINE_SEPARATOR);
            stringBuilder.append(str2);
            stringBuilder.append(LINE_SEPARATOR);
            stringBuilder.append(LINE_SEPARATOR);
            final CharSequence fromHtml = Html.fromHtml(stringBuilder.toString());
            dzo.ˎ(new o.dzo.a(this) {
                final /* synthetic */ HiSpaceObject ˎ;

                public void ˊ(String str) {
                    if (TextUtils.isEmpty(str)) {
                        evk.ˋ(this.ˎ.mContext, this.ˎ.mContext.getResources().getString(f.ॱꞌ), 1).ˋ();
                        return;
                    }
                    List arrayList = new ArrayList();
                    arrayList.add(str);
                    Uri uri = null;
                    if (1 == i) {
                        File ˎ = dse.ˎ(this.ˎ.mContext);
                        if (ˎ != null) {
                            this.ˎ.initLogProvider();
                            uri = CommonFileProvider.ˋ(this.ˎ.mContext, ˎ);
                        }
                    }
                    new dxz(this.ˎ.mContext, arrayList).ॱ("[" + this.ˎ.mContext.getString(n.ᐝॱ) + "]" + this.ˎ.mContext.getString(f.ꜝ)).ˏ(fromHtml).ˋ("application/zip").ˊ(uri).ᐝ();
                }
            });
            return;
        }
        evk.ˋ(this.mContext, this.mContext.getResources().getString(f.ʻʽ), 1).ˋ();
    }

    private void initLogProvider() {
        bmo o_bmo = new bmo();
        o_bmo.ˋ = ".zip";
        o_bmo.ˏ = new File(epp.ˊ(this.mContext));
        CommonFileProvider.ˏ("emaillog", o_bmo);
    }

    @JavascriptInterface
    public void showLogMessage() {
        cku.ˏ(this.mContext, enq.class, this.mContext.getResources().getString(f.ˏﹳ), null).ˋ(this.mContext, "SystemLogInfoDialog");
    }

    @JavascriptInterface
    public void gotoNative(String str, String str2) {
        new enn().ॱ(this.mContext, str, str2);
    }

    @JavascriptInterface
    public void loginRefreshUrl(String str) {
        loginWithCallback(str, null, null);
    }

    @JavascriptInterface
    public boolean isSupport(String str) {
        return enm.ˋ(str);
    }

    @JavascriptInterface
    public boolean isNeedUpdate(String str) {
        return false;
    }

    @JavascriptInterface
    public void callHuaweiApp(String str, String str2) {
        enm.ˊ(this.mContext, this.mHandler, str, str2);
    }

    @JavascriptInterface
    public void useCoupon(String str) {
        ear.ˊ(str, this.mContext);
    }

    @JavascriptInterface
    public void launchApp(String str, String[] strArr, String[] strArr2) {
        ced.ˊ(this.mContext, str);
        checkCampaignId(str);
    }

    @JavascriptInterface
    public void launchFastApp(String str) {
        RpkInfo rpkInfo = new RpkInfo();
        rpkInfo.setPackageName(str);
        FastSDKEngine.launchFastAppFromAppGallery(this.mContext, rpkInfo);
        checkCampaignId(str);
    }

    private void checkCampaignId(final String str) {
        this.mHandler.post(new Runnable(this) {
            final /* synthetic */ HiSpaceObject ˎ;

            public void run() {
                String access$500 = this.ˎ.getCampaignId();
                if (!dof.ॱ(access$500) && !dof.ॱ(str)) {
                    dgh.onEvent(new o.dge.d(ContentManager.getInstant().getContext(), f.ʽᐝ).ˏ("01|" + str + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + access$500).ˋ());
                }
            }
        });
    }

    @JavascriptInterface
    public void getCertificateChain(final String str) {
        if (etp.ˋ()) {
            Logger.ˋ(TAG, "device is root, not allow exchange!");
            showToastImpl(this.mContext.getString(exp$f.ʾॱ));
        } else if (VERSION.SDK_INT < 23 || this.mContext.checkSelfPermission("android.permission.READ_PHONE_STATE") == 0) {
            fco.ˋ(new o.fco.c(this) {
                final /* synthetic */ HiSpaceObject ॱ;

                public void ˋ(String str) {
                    this.ॱ.callJavascript(str, str);
                }
            });
        } else {
            final cku ˋ = cku.ˋ(null, this.mContext.getString(exp$f.ʽᐝ));
            ˋ.ˎ(-3, 8);
            ˋ.ॱ(-1, this.mContext.getString(exp$f.ˏ));
            ˋ.ॱ(-2, this.mContext.getString(exp$f.ॱˎ));
            ˋ.ˎ(this.mContext);
            ˋ.ॱ(new cks(this) {
                final /* synthetic */ HiSpaceObject ˊ;

                public void enableNetworking() {
                    PermissionChecker.ˋ((Activity) this.ˊ.mContext, 14);
                    ˋ.dismiss();
                }

                public void upgrade() {
                    ˋ.dismiss();
                }

                public void ˋ() {
                    ˋ.dismiss();
                }
            });
        }
    }

    private String getCampaignId() {
        if (this.mWebView == null) {
            return null;
        }
        String url = this.mWebView.getUrl();
        if (dof.ॱ(url)) {
            return null;
        }
        Map ˊॱ = this.mJsCallBack.ˊॱ(url);
        if (ˊॱ == null || ˊॱ.size() <= 0) {
            return null;
        }
        return (String) ˊॱ.get(WEBVIEW_PARAMS_CAMPAIGN_ID);
    }

    @JavascriptInterface
    public void loginForward(final String str) {
        this.mWebView.post(new Runnable(this) {
            final /* synthetic */ HiSpaceObject ˋ;

            public void run() {
                Context context = this.ˋ.mWebView.getContext();
                if (!doo.ˊ(context)) {
                    this.ˋ.showToast(context, context.getString(f.ʻʽ));
                } else if (UserSession.getInstance().isLoginSuccessful()) {
                    this.ˋ.refreshMyexchange(str);
                } else {
                    String str = "HiSpaceObject.loginForward";
                    eoj.ˋ().ˎ("HiSpaceObject.loginForward", new AccountBussinessListener(this) {
                        final /* synthetic */ AnonymousClass6 ॱ;

                        {
                            this.ॱ = r1;
                        }

                        public void onAccountBusinessResult(ccp o_ccp) {
                            if (o_ccp.ˎ == 102) {
                                this.ॱ.ˋ.refreshMyexchange(str);
                            }
                            eoj.ˋ().ˊ("HiSpaceObject.loginForward");
                        }
                    });
                    this.ˋ.gwLogin();
                }
            }
        });
    }

    @JavascriptInterface
    public void loginWithCallback(final String str, final String str2, final String str3) {
        this.mWebView.post(new Runnable(this) {
            final /* synthetic */ HiSpaceObject ˏ;

            public void run() {
                Context context = this.ˏ.mWebView.getContext();
                if (doo.ˊ(context)) {
                    String str = "HiSpaceObject.loginWithCallback";
                    eoj.ˋ().ˎ("HiSpaceObject.loginWithCallback", new AccountBussinessListener(this) {
                        final /* synthetic */ AnonymousClass8 ॱ;

                        {
                            this.ॱ = r1;
                        }

                        public void onAccountBusinessResult(final ccp o_ccp) {
                            this.ॱ.ˏ.mWebView.post(new Runnable(this) {
                                final /* synthetic */ AnonymousClass3 ॱ;

                                public void run() {
                                    if (o_ccp.ˎ == 102) {
                                        this.ॱ.ॱ.ˏ.callJavascript(str2);
                                        this.ॱ.ॱ.ˏ.refreshMyexchange(str);
                                        return;
                                    }
                                    this.ॱ.ॱ.ˏ.callJavascript(str3);
                                }
                            });
                            eoj.ˋ().ˊ("HiSpaceObject.loginWithCallback");
                        }
                    });
                    this.ˏ.gwLogin();
                    return;
                }
                this.ˏ.showToast(context, context.getString(f.ʻʽ));
            }
        });
    }

    private void gwLogin() {
        if (this.mWebView == null) {
            Logger.e(TAG, "gwLogin:mWebView is null!");
        } else if (this.mJsCallBack.ˎ(this.mWebView)) {
            ezl.ˎ().ˏ();
        } else {
            eod.ॱ(ContentManager.getInstant().getContext());
        }
    }

    private void callJavascript(final String str) {
        if (!dof.ॱ(str)) {
            this.mHandler.post(new Runnable(this) {
                final /* synthetic */ HiSpaceObject ˎ;

                public void run() {
                    this.ˎ.mWebView.loadUrl("javascript:window." + str + "();");
                }
            });
        }
    }

    private void callJavascript(final String str, final String str2) {
        if (!dof.ॱ(str)) {
            this.mHandler.post(new Runnable(this) {
                final /* synthetic */ HiSpaceObject ˎ;

                public void run() {
                    this.ˎ.mWebView.loadUrl("javascript:window." + str + "('" + str2 + "');");
                }
            });
        }
    }

    private void showToast(Context context, String str) {
        evk.ˋ(context, str, 0).ˋ();
    }

    @JavascriptInterface
    public void gotoForumHomePage(String str, String str2) {
        if (dof.ˋ(str) || dof.ˋ(str2)) {
            Logger.ˋ(TAG, "uri or userid null error");
            return;
        }
        fjb ˎ = fho.ˏ().ˋ("User").ˎ("UserHomePageActivity");
        IUserHomePageProtocol iUserHomePageProtocol = (IUserHomePageProtocol) ˎ.ˊ();
        iUserHomePageProtocol.setHeadUri(str);
        iUserHomePageProtocol.setUserId(str2);
        fiu.ˊ().ˏ(this.mContext, ˎ);
    }

    protected boolean isCanInstall() {
        if (this.mJsCallBack != null) {
            return this.mJsCallBack.ˋॱ(this.mJsCallBack.ˋˋ());
        }
        return false;
    }

    protected void requestWhiteList(d dVar) {
        if (this.canRequestWhiteList) {
            Logger.ˏ(TAG, "not in install list , canRequestWhiteList true");
            this.mJsCallBack.ˎ(new a(this, dVar));
            return;
        }
        Logger.ˏ(TAG, "not in install list , canRequestWhiteList false");
        onRequestWhiteListError(1);
    }

    private void onRequestWhiteListError(int i) {
        int i2;
        if (i == 3) {
            i2 = f.ʻʽ;
        } else {
            i2 = f.ʼॱ;
        }
        evk.ˋ(this.mContext, this.mContext.getResources().getString(i2), 1).ˋ();
    }

    @JavascriptInterface
    public void launchPostWap(String str, String str2) {
        if (dof.ˋ(str)) {
            Logger.ˋ(TAG, "launchPostWap url null");
        } else if (this.mJsCallBack.ˏॱ(str)) {
            if (Logger.ˎ()) {
                Logger.ˏ(TAG, "launchPostWap:" + enx.ॱ(str));
            }
            ((azj) fho.ˏ().ˋ("AGWebView").ॱ(azj.class)).ˋ(this.mContext, str, ent.ˋ(str2));
        } else {
            Logger.ˋ(TAG, "launchPostWap url not INTERNAL");
        }
    }

    @JavascriptInterface
    public String getClientParams() {
        if (Logger.ˎ()) {
            Logger.ˏ(TAG, "getClientParams");
        }
        return this.mJsCallBack.ˏ(this.mContext);
    }

    @JavascriptInterface
    public void getPostData(String str, String str2, String str3, String str4) {
        this.mJsCallBack.ॱ(str, str2, str3, str4);
    }

    @JavascriptInterface
    public void launchPage(final String str, final String str2, boolean z) {
        if (Logger.ˎ()) {
            Logger.ˏ(TAG, "launchPage url:" + enx.ॱ(str) + ";method:" + str2 + ";inSameWebView:" + z);
        }
        if (!dof.ॱ(str)) {
            if (!z) {
                ((azj) fho.ˏ().ˋ("AGWebView").ॱ(azj.class)).ॱ(this.mContext, str, str2);
            } else if (this.mJsCallBack == null) {
            } else {
                if (this.mJsCallBack.ˏॱ(str)) {
                    this.mHandler.post(new Runnable(this) {
                        final /* synthetic */ HiSpaceObject ˋ;

                        public void run() {
                            this.ˋ.mJsCallBack.ˏ(str, str2);
                        }
                    });
                } else {
                    Logger.ˋ(TAG, "url error,not INTERNAL.");
                }
            }
        }
    }

    @JavascriptInterface
    public void getAppsControlled(String str, String str2) {
        if (dof.ॱ(str)) {
            Logger.ˋ(TAG, "getAppsControlled appIds null");
            return;
        }
        try {
            if (str.split(",").length > 100) {
                Logger.ˋ(TAG, "getAppsControlled appId size > 100, too much !");
                return;
            }
            if (Logger.ˎ()) {
                Logger.ˏ(TAG, "getAppsControlled appIds:" + str);
            } else {
                Logger.ˏ(TAG, "getAppsControlled .");
            }
            ens.ˎ(this.mWebView, str, str2);
        } catch (Exception e) {
            Logger.ˋ(TAG, "getAppsControlled split appIds error");
        }
    }

    @JavascriptInterface
    public void exposure(final String str) {
        this.mHandler.post(new Runnable(this) {
            final /* synthetic */ HiSpaceObject ˋ;

            public void run() {
                String ˋˋ = this.ˋ.mJsCallBack.ˋˋ();
                if (ˋˋ == null || !this.ˋ.mJsCallBack.ˏॱ(ˋˋ)) {
                    Logger.ˏ(HiSpaceObject.TAG, "exposure url not in whitelist: " + enx.ॱ(ˋˋ));
                    return;
                }
                try {
                    JSONObject jSONObject = new JSONObject(str);
                    if (jSONObject.has("appDetailId")) {
                        ens.ˎ(this.ˋ.mContext, jSONObject.optString("appDetailId"));
                    }
                } catch (JSONException e) {
                    Logger.ˋ(HiSpaceObject.TAG, "HiSpaceObjectwap expose() exception is: " + e.toString());
                }
            }
        });
    }

    @JavascriptInterface
    public void questionFilled(String str, String str2) {
        Intent intent = new Intent();
        intent.setAction("com.huawei.appmarket.service.fill.vanattend.question");
        intent.putExtra("VAN_ATTEND_FILL_QUESTION_ID", str2);
        intent.putExtra("VAN_ATTEND_FILL_QUESTION_USERID", str);
        ll.ˏ(this.mContext.getApplicationContext()).ˋ(intent);
    }

    @JavascriptInterface
    public void skipToNetDiagnose() {
        this.mHandler.post(new Runnable(this) {
            final /* synthetic */ HiSpaceObject ॱ;

            {
                this.ॱ = r1;
            }

            public void run() {
                String ˋˋ = this.ॱ.mJsCallBack.ˋˋ();
                if (ˋˋ == null || !this.ॱ.mJsCallBack.ˏॱ(ˋˋ)) {
                    Logger.ˎ(HiSpaceObject.TAG, "skipToNetDiagnose not in whitelist.");
                } else {
                    eth.ॱ(this.ॱ.mContext);
                }
            }
        });
    }
}
